package com.etc.shiro.service;

import com.etc.shiro.mapper.ShiroUserMapper;
import com.etc.shiro.model.UserMst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserService {

    @Resource
    ShiroUserMapper mapper;

    public UserMst findUserByName(String username) {

        List<UserMst>  ulist = mapper.findInfoByUname(username);
        if (ulist == null || ulist.size() == 0) {
            return null;
        }
        return ulist.get(0);
    }

    @Transactional()
    public void saveUser(UserMst user) {
        mapper.insertSelective(user);
    }
}
